import Base from '@/services/base'

export default class service extends Base {

	/**
	 *  考试题目收藏(需要携带token)
	 *
	 *  mock地址：7d9bc0f4-0cfe-4e9b-acbf-8922e1d2ad73
	 *  测试地址：/api/exam/collectSubject
	 *
	 *  请求参数：paperId,subjectId,type,collectType
	 *
	 *  请求参数：param
	 *
	 * 	subjectId:题目id
	 * 	type:类型
	 * 	collectType：收藏类型：1，试题；2，学习
	 *
	 */
	async collectSubject(param) {
		const resp = await this.fly.post('/api/exam/collectSubject', param);
		return resp;

	}


	/**
	 *  保存考试结果(需要携带token)
	 *
	 *  mock地址：0b7cff27-3b49-49b0-a5d0-5521d99c6a0a
	 *  测试地址：/api/exam/saveExamResult
	 *
	 *  请求参数：examId
	 *
	 *  返回参数：
	 *
	 */
	async saveExamResult(examData) {
		return await this.fly.post('/api/exam/saveExamResult', examData);
	}

	/**
	 *  查询考试结果(需要携带token)
	 *
	 *  mock地址：418c5c5b-f231-4b14-99ef-894470bb1d4a
	 *  测试地址： /exam/queryExamResult
	 *
	 *  请求参数：examId
	 *
	 *  返回参数：
	 *
	 */
	async queryExamResult(examId, recordId) {
		return await this.fly.post('/api/exam/queryExamResult?examId=' + examId + '&recordId=' + recordId);
	}

	/**
	 *  题目解析(需要携带token)
	 *
	 *  mock地址：8d3125db-e591-4fe7-bb4c-1e303f756bd4
	 *  测试地址： /api/exam/historyPaperDetail
	 *
	 *  请求参数：examId
	 *
	 *  返回参数：
	 *
	 */
	async historyPaperDetail(type, examId, recordId, subjectId) {
		const resp = await this.fly.get('/api/exam/historyPaperDetail?type=' + type + '&examId=' + examId +
			'&recordId=' + recordId + '&subjectId=' + subjectId);
		return resp;
	}
	/**
	 * 错题集查询接口(需要携带token)
	 *
	 *  mock地址：f2c24b9f-a99d-4876-a46b-bc0fabfe6474
	 *  测试地址： /api/exam/errorPaperDetail
	 *
	 *  请求参数：examId
	 *
	 *  返回参数：
	 *
	 */

	async errorPaperDetail(examId) {
		const resp = await this.fly.post('f2c24b9f-a99d-4876-a46b-bc0fabfe6474', examId);
		return resp;
	}

	/**
	 * 智能自测获取选择项(需要携带token)
	 *
	 *  mock地址：8645f3e4-0f64-42fd-a410-b53a45bc5dcd
	 *  测试地址： /api/exam/smartTest/choices
	 *
	 */

	async smartTestChoices(ascription) {
		const resp = await this.fly.get('/api/exam/smartTest/choices?ascription=' + ascription);
		return resp;
	}

	/**
	 * examType     考试种类
	 *  1            快速练习
	 *  2            智能自测
	 *  3              无
	 *  4            历年真题
	 *  5            历史-继续答题
	 *  6            模考(公安)
	 *  7            任务
	 *  8            模考(执法)
	 *  9            错题重练
	 *    
	 */
	//参数由调用端传递
	async getExam(param) {
		const {
			examType
		} = param;
		if (examType == 1) {
			const requestParam = (({
				amount,
				ascription
			}) => ({
				amount,
				ascription
			}))(param)
			return await this.fly.get('/api/exam/getTest', requestParam);
		} else if (examType == 2) {
			return await this.fly.get('/api/exam/getTest', param);
		} else if (examType == 4 || examType == 8) { //历年真题，执法模考
			return await this.fly.get('/api/exam/continueExam', param);
		} else if (examType == 6 || examType == 7) {
			return await this.fly.get('/api/exam/mockExam', param);
		} else if (examType == 5) { //历史答题-继续答题
			param.type = 1
			return await this.fly.get('/api/exam/getHistoryByExamId', param);
		} else if (examType == 9) { //错题重练
			return await this.fly.get('/api/exam/getErrorPaper', param);
		}
	}

	/**
	 * 自主练习(需要携带token)
	 *
	 *  mock地址：e36c5937-c297-4f2d-9019-28b797282ea5
	 *  测试地址： /api/exam/selfExam
	 *
	 *  请求参数：param
	 * 	paperId：试卷id
	 *
	 */

	async selfExam(param) {
		if(param.isSecond){
			return await this.fly.get('/api/exam/goSelfExamSub', param);
		}
		return await this.fly.get('/api/exam/selfExam', param);
	}
	/**
	 * 保存学生考试试卷(需要携带token)
	 *
	 *  mock地址：4484fb64-9b40-43dd-8505-fee4e7fdda62
	 *  测试地址： /api/exam/saveExam
	 *
	 *  请求参数：param
	 * 	examId：考试试卷id
	 *
	 */

	async getExaming(param) {
		const resp = await this.fly.post('4484fb64-9b40-43dd-8505-fee4e7fdda62', param);
		return resp;
	}

	/**
	 * 历史答题列表(需要携带token)
	 *  mock地址：1fe48b10-6517-4b2f-bfa1-bfe25cef8d56
	 *  测试地址： /api/exam/historyExam
	 */
	async historyExam(param) {
		const resp = await this.fly.get('/api/exam/historyExam', param);
		return resp;
	}

	/**
	 * 纠错(需要携带token)
	 *  mock地址：05fc40fd-e279-49b2-aa08-d65299fd5061
	 *  测试地址： /api/exam/errorCollection
	 */
	async saveErrorCollection(param) {
		const resp = await this.fly.post('/api/exam/errorCollection', param);
		return resp;
	}

	/**
	 *mock地址：ae3f2e32-3a1a-464e-90be-a00e60a2d615
	 * 测试地址：/api/exam/simulation
	 * 
	 * 模拟大赛
	 */
	async simulationList(param) {
		return await this.fly.get('/api/exam/simulation', param);
	}

	/**
	 * 我要参赛
	 * @param {Object} param
	 */
	async joinCompetition(joinId) {
		return await this.fly.post("/api/exam/joinCompetition?joinId=" + joinId);
	}

	/**
	 * mock地址：5c7ca567-a04f-4d1c-b062-906f91b6c30e
	 * 测试地址：/api/study/topicList
	 *
	 * 历年真题(地区)
	 */
	async studyTopic(param) {
		return await this.fly.get('/api/exam/topicList', param);
	}

	/**
	 * 历年真题
	 * mock地址：d5fe0b8b-58c0-40e5-9517-86de781430ee
	 * 测试地址：/api/exam/pastExamPaper
	 */
	async pastExamPaper(param) {
		return await this.fly.get('/api/exam/pastExamPaper', param);
	}


}
